package org.shopen.ai.puremvc.model.settings
{
	import mx.collections.ArrayCollection;
	
	import org.shopen.ai.puremvc.model.algo.ISearchAlgo;
	import org.shopen.ai.puremvc.model.problem.IState;

	public class ManualSettings implements ISettings
	{
		public var initialState : IState;
		public var goalState : IState;
		public var algo : ISearchAlgo;
		public var performMode : PerformModeType;
		public var delay : uint = 5;
		
		public function ManualSettings(initialState : IState, goalState : IState, algo : ISearchAlgo, performMode : PerformModeType, delay : uint = 5)
		{
			this.initialState = initialState;
			this.goalState = goalState;
			this.algo = algo;
			this.performMode = performMode;
			this.delay = delay;
		}

		public function isValid():Boolean
		{
			var result : Boolean = false;
			if (invalidFields == null)
			{
				result = true;
			}
			else
			{
				result = invalidFields.length == 0;
			}
			return result;
		}
		
		public function get invalidFields():ArrayCollection
		{
			var result : ArrayCollection = new ArrayCollection();
			if (initialState == null)
			{
				result.addItem("Initial State");
			}
			if (goalState == null)
			{
				result.addItem("Goal State");
			}
			if (algo == null)
			{
				result.addItem("Algorithm");
			}
			if (performMode == null)
			{
				result.addItem("Perform Mode");
			}
			return result;
		}
		
	}
}